home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / PC Card Manager / CIncludes / Types.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-13  |  11.4 KB  |  446 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Types.h
  3.  
  4.      Contains:    Basic Macintosh data types.
  5.  
  6.      Version:    System 7.5
  7.  
  8.      DRI:        Nick Kledzik
  9.  
  10.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Warning:    *** APPLE INTERNAL USE ONLY ***
  14.                  This file may contain unreleased API's
  15.  
  16.      BuildInfo:    Built by:            Dave Falkenburg
  17.                  With Interfacer:    2.0d11   (PowerPC native)
  18.                  From:                Types.i
  19.                      Revision:        88
  20.                      Dated:            4/16/96
  21.                      Last change by:    ngk
  22.                      Last comment:    Make RefLabel FOR_SYSTEM8_PREEMPTIVE instead of cooperative.
  23.  
  24.      Bugs:        Report bugs to Radar component “System Interfaces”, “Latest”
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __TYPES__
  29. #define __TYPES__
  30.  
  31. #ifndef __CONDITIONALMACROS__
  32. #include <ConditionalMacros.h>
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT_SUPPORTED
  40. #pragma import on
  41. #endif
  42.  
  43. #if PRAGMA_ALIGN_SUPPORTED
  44. #pragma options align=mac68k
  45. #endif
  46.  
  47.  
  48. enum {
  49.     noErr                        = 0
  50. };
  51.  
  52. #ifndef NULL
  53. /* Symantec C compilers (but not C++) want NULL and nil to be (void*)0  */
  54. #if !defined(__cplusplus) && (defined(__SC__) || defined(THINK_C))
  55. #define NULL ((void *) 0)
  56. #else
  57. #define    NULL 0
  58. #endif
  59. #endif
  60.  
  61. #ifndef nil
  62. #define nil NULL
  63. #endif
  64. typedef unsigned char Byte;
  65. typedef signed char SignedByte;
  66. typedef Byte UInt8;
  67. typedef SignedByte SInt8;
  68. typedef unsigned short UInt16;
  69. typedef signed short SInt16;
  70. typedef unsigned long UInt32;
  71. typedef signed long SInt32;
  72. typedef UInt16 UniChar;
  73. typedef char *Ptr;
  74. /*  pointer to a master pointer */
  75. typedef Ptr *Handle;
  76. /* fixed point arithmatic type */
  77. typedef long Fixed;
  78. typedef Fixed *FixedPtr;
  79. typedef long Fract;
  80. typedef Fract *FractPtr;
  81. /*
  82. Note: on PowerPC extended is undefined.
  83.       on 68K when mc68881 is on, extended is 96 bits.  
  84.              when mc68881 is off, extended is 80 bits.  
  85.       Some old toolbox routines require an 80 bit extended so we define extended80
  86. */
  87. struct _extended80 { short exp; short man[4]; };
  88. struct _extended96 { short exp[2]; short man[4]; };
  89.  
  90. #if GENERATING68K
  91. #if defined(__MWERKS__)
  92. /* Note: Metrowerks on 68K doesn't declare 'extended' or 'comp' implicitly. */
  93. typedef long double extended;
  94. typedef struct comp { long hi,lo; } comp;
  95. #elif defined(THINK_C)
  96. /* Note: THINK C doesn't declare 'comp' implicitly and needs magic for 'extended' */
  97. typedef struct { short man[4]; } comp;
  98. typedef struct _extended80 __extended;    /*  <-- this line is magic */
  99. typedef __extended extended;
  100. #endif
  101. #endif
  102.  
  103. #if GENERATING68K && GENERATING68881
  104. typedef extended             extended96;
  105. #else
  106. typedef struct _extended96     extended96;
  107. #endif
  108.  
  109. #if GENERATING68K && !GENERATING68881
  110. typedef extended             extended80;
  111. #else
  112. typedef struct _extended80     extended80;
  113. #endif
  114.  
  115. /*
  116. Note: float_t and double_t are "natural" computational types
  117.       (i.e.the compiler/processor can most easily do floating point
  118.       operations with that type.) 
  119. */
  120. #if GENERATINGPOWERPC
  121. /* on PowerPC, double = 64-bit which is fastest.  float = 32-bit */
  122. typedef float float_t;
  123. typedef double double_t;
  124. #else
  125. /* on 68K, long double (a.k.a. extended) is always the fastest.  It is 80 or 96-bits */
  126. typedef long double float_t;
  127. typedef long double double_t;
  128. #endif
  129. struct SInt64 {
  130.     SInt32                             hi;
  131.     UInt32                             lo;
  132. };
  133. typedef struct SInt64 SInt64;
  134.  
  135. struct UInt64 {
  136.     UInt32                             hi;
  137.     UInt32                             lo;
  138. };
  139. typedef struct UInt64 UInt64;
  140.  
  141. /*
  142.     wide and UnsignedWide are being replace by SInt64 and UInt64 in the Math64 library and interfaces
  143. */
  144. typedef SInt64 wide;
  145. typedef SInt64 *WidePtr;
  146. typedef UInt64 UnsignedWide;
  147. typedef UInt64 *UnsignedWidePtr;
  148. #if defined(__SC__) && !defined(__STDC__) && defined(__cplusplus)
  149.     class __machdl HandleObject {};
  150. #if !GENERATINGPOWERPC
  151.     class __pasobj PascalObject {};
  152. #endif
  153. #endif
  154.  
  155. enum {
  156.     false                        = 0,
  157.     true                        = 1
  158. };
  159.  
  160. typedef unsigned char Boolean;
  161.  
  162. enum {
  163.     v                            = 0,
  164.     h                            = 1
  165. };
  166.  
  167. typedef SInt8 VHSelect;
  168. typedef long (*ProcPtr)();
  169. typedef pascal void (*Register68kProcPtr)();
  170. typedef ProcPtr *ProcHandle;
  171. #if GENERATINGCFM
  172. /*
  173.     Note that the RoutineDescriptor structure is defined in the 
  174.         MixedMode.h header 
  175. */
  176. typedef struct RoutineDescriptor *UniversalProcPtr;
  177. #else
  178. typedef ProcPtr UniversalProcPtr;
  179. #endif
  180. typedef UniversalProcPtr *UniversalProcHandle;
  181. typedef unsigned char Str255[256];
  182. typedef unsigned char Str63[64];
  183. typedef unsigned char Str32[33];
  184. typedef unsigned char Str31[32];
  185. typedef unsigned char Str27[28];
  186. typedef unsigned char Str15[16];
  187. /*
  188.     The type Str32 is used in many AppleTalk based data structures.
  189.     It holds up to 32 one byte chars.  The problem is that with the
  190.     length byte it is 33 bytes long.  This can cause weird alignment
  191.     problems in structures.  To fix this the type "Str32Field" has
  192.     been created.  It should only be used to hold 32 chars, but
  193.     it is 34 bytes long so that there are no alignment problems.
  194. */
  195. typedef unsigned char Str32Field[34];
  196. typedef unsigned char *StringPtr;
  197. typedef StringPtr *StringHandle;
  198. typedef const unsigned char *ConstStr255Param;
  199. typedef const unsigned char *ConstStr63Param;
  200. typedef const unsigned char *ConstStr32Param;
  201. typedef const unsigned char *ConstStr31Param;
  202. typedef const unsigned char *ConstStr27Param;
  203. typedef const unsigned char *ConstStr15Param;
  204. #ifdef __cplusplus
  205. inline unsigned char StrLength(ConstStr255Param string) { return (*string); }
  206. #else
  207. #define StrLength(string) (*(unsigned char *)(string))
  208. #endif
  209. #if OLDROUTINENAMES
  210. #define Length(string) StrLength(string)
  211. #endif
  212. /* error code */
  213. typedef short OSErr;
  214. typedef short ScriptCode;
  215. typedef short LangCode;
  216. typedef short RegionCode;
  217. typedef unsigned long FourCharCode;
  218. typedef short CharParameter;
  219.  
  220. enum {
  221.     normal                        = 0,
  222.     bold                        = 1,
  223.     italic                        = 2,
  224.     underline                    = 4,
  225.     outline                        = 8,
  226.     shadow                        = 0x10,
  227.     condense                    = 0x20,
  228.     extend                        = 0x40
  229. };
  230.  
  231. typedef unsigned char Style;
  232. typedef short StyleParameter;
  233. typedef Style StyleField;
  234. /*
  235.     CharParameter is only used in function parameter lists.  
  236.     StyleParameter is only used in function parameter lists.
  237.     StyleField is only used in struct fields.  
  238.     The original Macintosh toolbox in 68K pascal defined Style as a SET.  
  239.     Both Style and CHAR can occupy 8-bits in packed records or 16-bits when used as fields
  240.     in non-packed records or as parameters. 
  241.     These intermediate types hide that difference.
  242. */
  243. typedef FourCharCode OSType;
  244. typedef FourCharCode ResType;
  245. typedef OSType *OSTypePtr;
  246. typedef ResType *ResTypePtr;
  247. struct Point {
  248.     short                             v;
  249.     short                             h;
  250. };
  251. typedef struct Point Point;
  252.  
  253. typedef Point *PointPtr;
  254. struct Rect {
  255.     short                             top;
  256.     short                             left;
  257.     short                             bottom;
  258.     short                             right;
  259. };
  260. typedef struct Rect Rect;
  261.  
  262. typedef Rect *RectPtr;
  263. /*
  264.     kVariableLengthArray is used in array bounds to specify a variable length array.
  265.     It is ususally used in variable length structs when the last field is an array
  266.     of any size.  Before ANSI C, we used zero as the bounds of variable length 
  267.     array, but that is illegal in ANSI C.  Example:
  268.     
  269.         struct FooList 
  270.         {
  271.             short     listLength;
  272.             Foo        elements[kVariableLengthArray];
  273.         };
  274. */
  275.  
  276. enum {
  277.     kVariableLengthArray        = 1
  278. };
  279.  
  280. /* Numeric version part of 'vers' resource */
  281. struct NumVersion {
  282.     UInt8                             majorRev;                    /*1st part of version number in BCD*/
  283.     UInt8                             minorAndBugRev;                /*2nd & 3rd part of version number share a byte*/
  284.     UInt8                             stage;                        /*stage code: dev, alpha, beta, final*/
  285.     UInt8                             nonRelRev;                    /*revision level of non-released version*/
  286. };
  287. typedef struct NumVersion NumVersion;
  288.  
  289. /* Version Release Stage Codes */
  290.  
  291. enum {
  292.     developStage                = 0x20,
  293.     alphaStage                    = 0x40,
  294.     betaStage                    = 0x60,
  295.     finalStage                    = 0x80
  296. };
  297.  
  298. /* Wrapper so NumVersion can be accessed as a 32-bit value */
  299. union NumVersionVariant {
  300.     NumVersion                         parts;
  301.     unsigned long                     whole;
  302. };
  303. typedef union NumVersionVariant NumVersionVariant;
  304.  
  305. /* 'vers' resource format */
  306. struct VersRec {
  307.     NumVersion                         numericVersion;                /*encoded version number*/
  308.     short                             countryCode;                /*country code from intl utilities*/
  309.     Str255                             shortVersion;                /*version number string - worst case*/
  310.     Str255                             reserved;                    /*longMessage string packed after shortVersion*/
  311. };
  312. typedef struct VersRec VersRec;
  313.  
  314. typedef VersRec *VersRecPtr;
  315. typedef VersRecPtr *VersRecHndl;
  316. typedef SInt32 OSStatus;
  317. typedef void *LogicalAddress;
  318. typedef const void *ConstLogicalAddress;
  319. typedef UInt8 *BytePtr;
  320. typedef UInt32 ByteCount;
  321. typedef UInt32 ByteOffset;
  322. typedef UInt32 ItemCount;
  323. typedef void *PhysicalAddress;
  324. typedef UInt32 OptionBits;
  325. typedef UInt32 PBVersion;
  326. typedef SInt32 Duration;
  327. typedef UInt64 AbsoluteTime;
  328.  
  329. enum {
  330.     kSizeOfTimeObject            = 16
  331. };
  332.  
  333. /* TimeObject type definitions */
  334. struct TimeObject {
  335.     UInt8                             hidden[16];
  336. };
  337. typedef struct TimeObject TimeObject;
  338.  
  339. typedef TimeObject *TimeObjectPtr;
  340. typedef const TimeObject *ConstTimeObjectPtr;
  341. struct TimeObjectInterval {
  342.     UInt8                             hidden[16];
  343. };
  344. typedef struct TimeObjectInterval TimeObjectInterval;
  345.  
  346. typedef TimeObjectInterval *TimeObjectIntervalPtr;
  347. typedef const TimeObjectInterval *ConstTimeObjectIntervalPtr;
  348. #if FOR_SYSTEM8_PREEMPTIVE
  349. /*
  350.     RefLabels: these are non-localizable identifiers for system objects. These should
  351.     be passed by reference.  
  352. */
  353. struct RefLabel {
  354.     OSType                             creator;                    /* creator of the object.  should be the same as the application signature.*/
  355.     OSType                             id;                            /* uniquely identifies the object within a scope defined by semantics of the object*/
  356. };
  357. typedef struct RefLabel RefLabel;
  358.  
  359. #endif
  360. #define kInvalidID     0
  361.  
  362. enum {
  363.     kNilOptions                    = 0
  364. };
  365.  
  366. /*
  367.     Who implements what debugger functions:
  368.     
  369.     Name            MacsBug            Macintosh Debugger                    Copland Debugger
  370.     ----------        -----------        -----------------------------        -------------------
  371.     Debugger        yes                InterfaceLib maps to DebugStr        yes
  372.     DebugStr        yes                yes                                    yes
  373.     Debugger68k        yes                InterfaceLib maps to DebugStr        obsolete?
  374.     DebugStr68k        yes                InterfaceLib maps to DebugStr        obsolete?
  375.     debugstr        yes                InterfaceLib maps to DebugStr        yes
  376.     SysBreak        no                InterfaceLib maps to SysError        obsolete?
  377.     SysBreakStr        no                InterfaceLib maps to SysError        obsolete?
  378.     SysBreakFunc    no                InterfaceLib maps to SysError        obsolete?
  379.     SysDebug        ?                ?                                    ?
  380.     SysDebugStr        ?                ?                                    ?
  381.     LLDebugger        no                yes                                    Low Level Nub
  382.     LLDebugStr        no                yes                                    Low Level Nub
  383. */
  384. #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  385. extern pascal void Debugger(void )
  386.  ONEWORDINLINE(0xA9FF);
  387.  
  388. extern pascal void DebugStr(ConstStr255Param debuggerMsg)
  389.  ONEWORDINLINE(0xABFF);
  390.  
  391. #endif
  392. #if FOR_SYSTEM8_PREEMPTIVE
  393. /* Low level Copland debugger */
  394. extern pascal void LLDebugger(void );
  395.  
  396. extern pascal void LLDebugStr(ConstStr255Param debuggerMsg);
  397.  
  398. #endif
  399. #if FOR_SYSTEM7_ONLY
  400. /* Only for System 7 native drivers */
  401. extern void SysDebug(void );
  402.  
  403. extern void SysDebugStr(ConstStr255Param str);
  404.  
  405. #endif
  406. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  407. /* SADE break points */
  408. extern pascal void SysBreak(void )
  409.  THREEWORDINLINE(0x303C, 0xFE16, 0xA9C9);
  410.  
  411. extern pascal void SysBreakStr(ConstStr255Param debuggerMsg)
  412.  THREEWORDINLINE(0x303C, 0xFE15, 0xA9C9);
  413.  
  414. extern pascal void SysBreakFunc(ConstStr255Param debuggerMsg)
  415.  THREEWORDINLINE(0x303C, 0xFE14, 0xA9C9);
  416.  
  417. #if CGLUESUPPORTED
  418. extern void debugstr(const char *debuggerMsg);
  419.  
  420. #endif
  421. #endif
  422. #if FOR_SYSTEM7_ONLY
  423. /* old names for Debugger and DebugStr */
  424. extern pascal void Debugger68k(void )
  425.  ONEWORDINLINE(0xA9FF);
  426.  
  427. extern pascal void DebugStr68k(ConstStr255Param debuggerMsg)
  428.  ONEWORDINLINE(0xABFF);
  429.  
  430. #endif
  431.  
  432. #if PRAGMA_ALIGN_SUPPORTED
  433. #pragma options align=reset
  434. #endif
  435.  
  436. #if PRAGMA_IMPORT_SUPPORTED
  437. #pragma import off
  438. #endif
  439.  
  440. #ifdef __cplusplus
  441. }
  442. #endif
  443.  
  444. #endif /* __TYPES__ */
  445.  
  446.